package com.xx.pmis.services.implementations;

import java.util.List;

import com.xx.pmis.model.Stock;
import com.xx.pmis.persistence.dao.StockDAO;
import com.xx.pmis.services.StockService;

public class StockServiceImpl implements StockService {
	StockDAO stockDAO = null;

	public StockServiceImpl(StockDAO stockDAO) {
		super();
		this.stockDAO = stockDAO;
	}

	public void saveOrUpdateStock(Stock stock) throws Exception {
		stockDAO.saveOrUpdate(stock);
	}

	public void saveStock(Stock stock) throws Exception {
		stockDAO.save(stock);
	}

	public void deleteStock(Stock stock) throws Exception {
		stockDAO.delete(stock);
	}

	public Stock getStockByStockID(String stockID) throws Exception {
		Stock stock = stockDAO.getStockByStockID(stockID);
		return stock;
	}

	public List<Stock> getAllStock() throws Exception {
		List<Stock> stocks = stockDAO.getAllStock();
		return stocks;
	}

	public List<Stock> getAllStockByPage(int currentPage, int lineSize) throws Exception {
		List<Stock> stocks = stockDAO.getAllStockByPage(currentPage, lineSize);
		return stocks;
	}

	public int getCountOfStock() throws Exception {
		return stockDAO.getAllStock().size();
	}

}
